home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / msjdemo.c < prev    next >
C/C++ Source or Header  |  1988-12-15  |  3KB  |  101 lines

  1.  
  2. /* demo.c -- after Microsoft Systems Journal, Nov. 1988, p. 8 */
  3.  
  4. #include "video.h"
  5. #include <time.h>
  6.  
  7.  
  8. int buffer[3][510];  /* screen region save areas */
  9.  
  10.  
  11. void delay( double sec )
  12. {
  13.     time_t StartTime, EndTime;
  14.  
  15.     time (&StartTime);
  16.     time (&EndTime);
  17.     while ( difftime( EndTime,StartTime ) < sec )
  18.         time (&EndTime);
  19. }
  20.  
  21.  
  22. main()
  23. {
  24.     char TextColor = 0x07;
  25.     char BorderColor = 0x0F;
  26.     char WinColor1, WinColor2, WinColor3;
  27.     int i,j;
  28.  
  29.     /* -- init video struc -- */
  30.  
  31.     MSJ_GetVideoParms( &video );
  32.  
  33.     /* -- set attributes for monochrome or color -- */
  34.  
  35.     if ( video.ColorFlag )
  36.     {
  37.         WinColor1 = 0x1F;
  38.         WinColor2 = 0x4F;
  39.         WinColor3 = 0x6F;
  40.     }
  41.     else
  42.     {
  43.         WinColor1 = 0x0F;
  44.         WinColor2 = 0x70;
  45.         WinColor3 = 0x0F;
  46.     }
  47.  
  48.     /* -- clear screen and fill it with text -- */
  49.  
  50.     MSJ_ClrScr( TextColor, &video );
  51.     for ( i = 0; i < video.rows; i++ )
  52.         for ( j = 0; j <= 52; j += 26 )
  53.             MSJ_DispString( "Microsoft Systems Journal", i, j, TextColor, 
  54.                         &video );
  55.  
  56.     delay( 2.0 );
  57.  
  58.     /* -- open a window -- */
  59.     MSJ_SaveRegion( 5, 2, 14, 34, buffer[0], &video );
  60.     MSJ_ClrRegion( 6, 3, 13, 33, WinColor1 );
  61.     MSJ_TextBox( 5, 2, 14, 34, BorderColor, &video );
  62.     for ( i = 6; i < 14; i++ )
  63.         MSJ_DispString( "Open the first window here...", i, 4, WinColor1,
  64.                     &video );
  65.  
  66.     delay( 2.0 );
  67.  
  68.     /* -- open a second window -- */
  69.  
  70.     MSJ_SaveRegion( 2, 48, 12, 74, buffer[1], &video );
  71.     MSJ_ClrRegion( 3,49, 11, 73, WinColor2 );
  72.     MSJ_TextBox( 2, 48, 12, 74, BorderColor, &video );
  73.     for ( i = 3; i < 12; i++ )
  74.         MSJ_DispString( "Then the second here...", i, 50, WinColor2,
  75.                     &video );
  76.  
  77.     delay( 2.0 );
  78.  
  79.     /* -- open a third window overlapping the first two -- */
  80.  
  81.     MSJ_SaveRegion( 9, 25, 22, 60, buffer[2], &video );
  82.     MSJ_ClrRegion( 10, 26, 21, 59, WinColor3 );
  83.     MSJ_TextBox( 9, 25, 22, 60, BorderColor, &video );
  84.     for ( i = 10; i < 22; i++ )
  85.         MSJ_DispString( "And finally a third window here.", i, 27, WinColor3,
  86.                     &video );
  87.  
  88.     delay( 4.0 );
  89.  
  90.     /* -- close all windows and exit -- */
  91.     MSJ_RestRegion( 9, 25, 22, 60, buffer[2], &video );
  92.     delay( 1.0 );
  93.     MSJ_RestRegion( 2, 48, 12, 74, buffer[1], &video );
  94.     delay( 1.0 );
  95.     MSJ_RestRegion( 5,  2, 14, 34, buffer[0], &video );
  96.     delay( 1.0 );
  97.     MSJ_ClrScr( TextColor, &video );
  98.  
  99.     exit (0);
  100. }
  101.